﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PDAMain.DAL;
using PDAMain.Entity;
namespace PDAMain
{
    public partial class ModifyPassword : Form
    {
        public ModifyPassword()
        {
            InitializeComponent();
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            FuntionView formShow = new FuntionView();
            formShow.Show();
            this.Close();
        }

        private void btnComfirm_Click_1(object sender, EventArgs e)
        {
            if (txtoldp.Text.ToString().Trim() =="")
            {
                MessageBox.Show("请输入旧密码！");
                return;
            }
            if(txtNewP.Text.ToString().Trim()=="")
            {
                MessageBox.Show("请输入新密码！");
                return;
            }
            if (txtComfirmP.Text.ToString().Trim()=="")
            {
                MessageBox.Show("请输入确认密码！");
                return;
            }
            if (txtNewP.Text.Length < 6)
            {
                MessageBox.Show("密码简单！");
                txtNewP.Text = "";
                return;
            }
            if (txtNewP.Text.ToString().Trim() != txtComfirmP.Text.ToString().Trim())
            {
                MessageBox.Show("密码不一致！");
                txtComfirmP.Text = "";
                return;
            }
            //webservice 修改密码操作
            bool Flag=false;
            try
            {
                //pdaWebReference.PdaService pda = PublicMethods.getobject();
                Flag = DataHelper.UserDao.modifyPassword(Identity.dutyPerson, txtoldp.Text.ToString().Trim(), txtNewP.Text.ToString().Trim());
                if (Flag)
                {
                    MessageBox.Show("修改成功");
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            catch
            {
                MessageBox.Show("请检查网络连接！");
                return;
            }
            if (Flag == true)
            {
                FuntionView formShow = new FuntionView();
                formShow.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("原密码错误！");
                return;
            }
        }
    }
}